<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>localForage Tests!</title>

    <link rel="stylesheet" href="/bower_components/mocha/mocha.css">
  </head>
  <body>
    <div id="mocha"></div>

    <script src="/bower_components/assert/assert.js"></script>
    <script src="/bower_components/mocha/mocha.js"></script>

    <script src="/bower_components/expect/index.js"></script>

    <script>

        try {
            window.originalIdbOpen = window.indexedDB.open;
            window.indexedDB.open = function faultyIdbOpen() {
                var openreq = {};
                setTimeout(function() {
                    if (typeof openreq.onerror === 'function') {
                        openreq.onerror(new Event(new Error('OpenDatabase Faulty Driver Test!')));
                    }
                });
                return openreq;
            };
        } catch (error) { }

        try {
            window.originalOpenDatabase = window.openDatabase;
            window.openDatabase = function faultyOpenDatabase() {
                throw new Error('OpenDatabase Faulty Driver Test!');
            };
        } catch (error) { }

        try {
            window.originalLocalStorageSetItem = window.localStorage.setItem;
            window.localStorage.setItem = function faultySetItemQuotaError() {
              throw new DOMException('The quota has been exceeded.', 'QuotaExceededError');
            };

        } catch (error) { }

    </script>

    <!-- Modernizr  -->
    <script src="/bower_components/modernizr/modernizr.js"></script>

    <script> mocha.setup('bdd'); </script>

    <!-- localForage -->
    <script src="/dist/localforage.js"></script>

    <!-- specs -->
    <script src="/test/test.faultydriver.js"></script>

    <!-- Disable warning -->
    <script> window.console.warn = function(){}; </script>

    <!-- Run tests -->
    <script> mocha.run(); </script>
  </body>
</html>
